package com.heima.article.task;

import com.heima.article.service.IApArticleService;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class HotArticleTask {
    @Autowired
    private IApArticleService articleService;
    //    @Scheduled(cron = "0/5 * * * * ?")
    @XxlJob("computeHotArticleJob")
    public ReturnT<String> computeHotArticleJob(String param) throws Exception {
        log.info("开始执行每日文章分值计算任务...");
        try {
            articleService.compute();
        } catch (Exception e) {
            e.printStackTrace();
            return ReturnT.FAIL;
        }
        return ReturnT.SUCCESS;
    }
}
